<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>props 初体验</title>
</head>

<body>
    <div id="root"> </div>

    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/babel.min.js"></script>

    <script type="text/babel">
        //声明变量
        let zhouhua = {
            name: '洲华',
            age: 18,
            gender: '女'
        };

        let hukai = {
            name: '胡凯',
            age: 20,
            gender: '男'
        }

        //声明组件
        class Student extends React.Component{
            render(){
                //结构赋值
                let {name, age, gender} = this.props;
                return <div>
                        <ul>
                            <li>姓名: {name}</li>
                            <li>年龄: {age}</li>
                            <li>性别: {gender}</li>
                        </ul>
                    </div>
            }
        }

        //渲染
        ReactDOM.render(<div>
                <Student a={100} name={zhouhua.name} age={zhouhua.age} gender={zhouhua.gender} />
                <Student name={hukai.name} age={hukai.age} gender={hukai.gender} />
                {/*上下 两个写法是等效的*/}
                <Student {...hukai} />
                </div>    
            , document.querySelector("#root"));
        

    </script>
</body>

</html>